package com.lp.guoguo.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class CaffeineConfig {
    
    @Bean
    public Cache<String, Object> caffeineCache() {
        return Caffeine.newBuilder()
                // 初始容量，根据实际业务估算
                .initialCapacity(100)
                // 最大容量，根据实际业务估算
                .maximumSize(500)
                // 过期时间：最后一次写入后过期
                .expireAfterWrite(30, TimeUnit.MINUTES)
                .build();
    }
} 